package com.yycwxt.modules.admin.store;


import com.yycwxt.domain.Store;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StoreService { // mybatis-plus 继承 ServiceImpl<StoreMapper, Store>

    private final StoreMapper storeMapper;

    public StoreService(@Autowired StoreMapper storeMapper) {this.storeMapper = storeMapper;}

    public List<Store> selectAll(){
        return storeMapper.selectAll();
    }

    public List<Store> selectByInput(String input){
        return storeMapper.selectByInput(input);
    }

    public List<Store> selectByInput2(String input){
        Map<String, Object> map = new HashMap<>();
        map.put("input",input);
        return storeMapper.selectByInput2(map);
    }

    @Transactional
    public int deleteById(Integer id){
        return storeMapper.deleteById(id);
    }


    @Transactional
    public int updateById(Store store){
        return storeMapper.updateById(store);
    }

    // 使用mybatis-plus 就删除这段代码
    @Transactional //dml操作要启用事务
    public int addStore(Store store) {
        return storeMapper.add(store);
    }

    // 业务逻辑层：根据业务实际需求来调用所需要的功能
}
